clear all

version 14 

set autotabgraphs on
set more off
set matsize 10000

global base "X:\Dropbox\educacion superior 2021\submission\EDCC\For publication\Replication package\Data"
cd "$base"
use "output/panel_final"

*** Polinomial fit

twoway 	(lpoly skills_cr_r3 wi_r3 if sex == 0, lcolor(gs10) lwidth(medthick)) ///
		(lpolyci skills_cr_r3 wi_r3 if sex == 0, nofit ciplot(rline) alwidth(medthin) alcolor(gs10)) ///
		(lpoly skills_cr_r3 wi_r3 if sex == 1, lpattern(dash) lcolor(gs1) lwidth(medthin)) ///
		(lpolyci skills_cr_r3 wi_r3 if sex == 1, nofit ciplot(rline) alpattern(dash) alwidth(vthin) alcolor(gs1)) ///
		if panel1234 == 1 ///
		, name(wealth_cskills, replace) ///
		xtitle("Wealth index (15 years old)") ytitle("Cognitive skills - standardized index") ///
		legend(order(1 "male" 2 "95% CI" 3 "female" 4 "95% CI")) ///
		yscale(range(-2.5 1.5)) ylabel(-2(1)1, glcolor(gs14) glwidth(vthin)) ///
		graphregion(color(white))

twoway 	(lpoly skills_nc2_r3 wi_r3 if sex == 0, lcolor(gs10) lwidth(medthick)) ///
		(lpolyci skills_nc2_r3 wi_r3 if sex == 0, nofit ciplot(rline) alwidth(medthin) alcolor(gs10)) ///
		(lpoly skills_nc2_r3 wi_r3 if sex == 1, lpattern(dash) lcolor(gs1) lwidth(medthin)) ///
		(lpolyci skills_nc2_r3 wi_r3 if sex == 1, nofit ciplot(rline) alpattern(dash) alwidth(vthin) alcolor(gs1)) ///
		if panel1234 == 1 ///
		, name(wealth_cskills, replace) ///
		xtitle("Wealth index (15 years old)") ytitle("Non-cognitive skills - standardized index") ///
		legend(order(1 "male" 2 "95% CI" 3 "female" 4 "95% CI")) ///
		yscale(range(-2.5 1.5)) ylabel(-2(1)1, glcolor(gs14) glwidth(vthin)) ///
		graphregion(color(white))

/* color version
twoway 	(lpolyci skills_cr_r3 wi_r3 if sex == 0, ciplot(rarea) alwidth(none) clcolor(blue) fcolor(blue%50) fi(20)) ///
		(lpolyci skills_cr_r3 wi_r3 if sex == 1, ciplot(rarea) alwidth(none) clcolor(green) fcolor(green%50) fi(20)) ///
		if panel1234 == 1 ///
		, name(wealth_nckills, replace) ///
		xtitle("Wealth index (15 years old)") ytitle("Non-cognitive skills - standardized index") ///
		legend(order(1 "95% CI" 2 "male" 3 "95% CI" 4 "female")) ///
		yscale(range(-2.5 2.5)) ylabel(-2(1)2, glcolor(gs14)) ///
		graphregion(color(white))

twoway 	(lpolyci skills_nc2_r3 wi_r3 if sex == 0, ciplot(rarea) alwidth(none) clcolor(blue) fcolor(blue%50) fi(20)) ///
		(lpolyci skills_nc2_r3 wi_r3 if sex == 1, ciplot(rarea) alwidth(none) clcolor(green) fcolor(green%50) fi(20)) ///
		if panel1234 == 1 ///
		, name(wealth_nckills, replace) ///
		xtitle("Wealth index (15 years old)") ytitle("Non-cognitive skills - standardized index") ///
		legend(order(1 "95% CI" 2 "male" 3 "95% CI" 4 "female")) ///
		yscale(range(-2.5 2.5)) ylabel(-2(1)2, glcolor(gs14)) ///
		graphregion(color(white))
*/
		
*** density plots

ksmirnov skills_cr_r3, by(sex) exact
local p_cskills = `r(p_exact)'

twoway 	(kdensity skills_cr_r3 if sex == 0, lcolor(gs10) lwidth(medthick)) ///
		(kdensity skills_cr_r3 if sex == 1, lpattern(dash) lcolor(gs1) lwidth(medthin)) ///
		if panel1234 == 1 ///
		, name(density_cskills, replace) ///
		legend(order(1 "male" 2 "female")) ///
		xscale(range(-4.3 4.3)) ///
		xline(0, lcolor(black) lwidth(thin)) ///
		ylabel(, glcolor(gs14)) ///
		ytitle("") xtitle("Cognitive skills - standardized index") ///
		graphregion(color(white))

ksmirnov skills_nc2_r3, by(sex) exact
local p_ncskills = `r(p_exact)'

twoway  (kdensity skills_nc2_r3 if sex == 0, lcolor(gs10) lwidth(medthick)) ///
		(kdensity skills_nc2_r3 if sex == 1, lpattern(dash) lcolor(gs1) lwidth(medthin)) ///
		if panel1234 == 1 ///
		, name(density_ncskills, replace) ///
		legend(order(1 "male" 2 "female")) ///
		xscale(range(-4.3 4.3)) ///
		xline(0, lcolor(black) lwidth(thin)) ///
		ylabel(, glcolor(gs14)) ///
		ytitle("") xtitle("Non-cognitive skills - standardized index") ///
		graphregion(color(white))
